package com.xzc.tmp.test;

import com.alibaba.fastjson.JSON;
import org.junit.Test;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class test {
    public String aaa = "1";
    public static final SimpleDateFormat sdf = new SimpleDateFormat("YYYYMM");

    @Test
    public void test() {
        String abc = "1,2,3";
        System.out.print(Arrays.asList(abc.split(",")));
    }

    @Test
    public void test0() {
        Map<String, test> abc = new HashMap<>();
        abc.put("1", new test());
        abc.put("2", new test());
        System.out.print(JSON.toJSONString(abc, true));
    }

    @Test
    public void test1() {
        List<String> out = new ArrayList<>();
        Calendar cl = Calendar.getInstance();
        out.add(sdf.format(cl.getTime()));
        for (int i = 1; i < 6; i++) {
            cl.add(Calendar.MONTH, -1);
            out.add(sdf.format(cl.getTime()));
        }
        System.out.println(out);
    }

    @Test
    public void testTime() throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String time1 = "2018-10-01 14:07:35";
//        System.out.println(simpleDateFormat.parse(time1).getTime());
        System.out.println(simpleDateFormat.format(new Date(1599271204665L)));
    }

    @Test
    public void testMoney() {
        BigDecimal money = new BigDecimal("77");
        money = money.divide(new BigDecimal(100));
        System.out.println(money.doubleValue());
        System.out.println(String.valueOf(money.doubleValue()));

        BigDecimal bigDecimal = new BigDecimal("1.0");
        BigDecimal fen = bigDecimal.multiply(new BigDecimal(100));
        String fenStr = String.valueOf(fen.intValue());
        System.out.println(fenStr);
    }

}
